package fr.louloutes.lolshooter.engine.objects.weapons;

import android.content.res.Resources;

/**
 * Class Weapon: weapon handling.
 * 
 * @author Louloute
 * 
 */
public abstract class Weapon
{
	float rof; // rate of fire
	int damage = 1;
	int splash = 0;
	double speed = 1;
	int accuracy = 1;
	double angle = 0;

	final int milliBetweenFire;
	long lastFired = 0;
	long extraTime = 0;

	/**
	 * Constructor with initlaization.
	 * 
	 * @param rof
	 */
	public Weapon( float rof )
	{
		milliBetweenFire = ( int ) ( 1000 * rof );
	}

	/**
	 * Can the weapon fire at this time.
	 * 
	 * @param currentTime
	 * @return
	 */
	public boolean canFire( long currentTime )
	{
		if ( currentTime - lastFired + extraTime > milliBetweenFire )
		{
			return true;
		}

		return false;
	}

	/**
	 * Fire a bullet.
	 * 
	 * @param currentTime
	 */
	public void fire( long currentTime )
	{
		extraTime = currentTime - lastFired - milliBetweenFire;
		lastFired = currentTime;

	}

	/**
	 * Get a projectile.
	 * 
	 * @param res
	 * @return
	 */
	abstract public Projectile getProjectile( Resources res );

	public float getRof()
	{
		return rof;
	}

	public void setRof( float rof )
	{
		this.rof = rof;
	}

	public int getDamage()
	{
		return damage;
	}

	public void setDamage( int damage )
	{
		this.damage = damage;
	}

	public int getSplash()
	{
		return splash;
	}

	public void setSplash( int splash )
	{
		this.splash = splash;
	}

	public double getSpeed()
	{
		return speed;
	}

	public void setSpeed( double speed )
	{
		this.speed = speed;
	}

	public int getAccuracy()
	{
		return accuracy;
	}

	public void setAccuracy( int accuracy )
	{
		this.accuracy = accuracy;
	}

	public double getAngle()
	{
		return angle;
	}

	public void setAngle( double angle )
	{
		this.angle = angle;
	}

}
